<template>
  <el-dialog
    title="批量提取SKU"
    width="400"
    :modelValue="modelValue"
    @close="handleClose"
    draggable
    align-center
    :z-index="2000"
  >
    <div class="h-[460px]">
      <div class="text-right mb-[8px]">
        <el-button type="primary" @click="copyText(data)">复制</el-button>
      </div>
      <el-input
        v-model="data"
        :autosize="{ minRows: 18, maxRows: 18 }"
        type="textarea"
        placeholder="复制内容"
      />
    </div>
    <template #footer>
      <div class="dialog-button">
        <el-button :disabled="loading" @click="handleClose(false)">
          {{ disabled ? "关闭" : "取消" }}
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup lang="jsx">
import { ElMessage } from "element-plus";
import { copyText } from "@/utils/tools.js";
const props = defineProps({
  modelValue: { type: Boolean, default: false },
  disabled: { type: Boolean, default: false },
  data: { type: Array, default: () => [] },
});
const { data } = toRefs(props);
const emit = defineEmits(["update:modelValue", "refresh", "close"]);
const loading = ref();
const handleClose = async (refresh) => {
  emit("update:modelValue", false);
  emit("close");
  if (refresh) emit("refresh");
};
</script>
